{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 一、知识库构建"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from RAG.PaddleEmbedding import PaddleEmbedding\n",
    "from RAG.VectorBase import VectorStore\n",
    "from RAG.utils import ReadFiles\n",
    "\n",
    "embedding_model = \"rocketqa-zh-base-query-encoder\"\n",
    "\n",
    "docs = ReadFiles('../../data/history_24').get_content(max_token_len=600, cover_content=150) # 获得data目录下的所有文件内容并分割\n",
    "vector = VectorStore(docs)\n",
    "#embedding = ZhipuEmbedding() # 创建EmbeddingModel\n",
    "embedding = PaddleEmbedding(model=embedding_model) # 创建EmbeddingModel\n",
    "#vector.get_vector_batch(EmbeddingModel=embedding,batch=batch)\n",
    "vector.get_vector(EmbeddingModel=embedding)\n",
    "\n",
    "vector.persist(path='../../storage/history_24') # 将向量和文档内容保存到storage目录下，下次再用就可以直接加载本地的数据库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
